package com.tanhua;

import com.tanhua.autoconfig.template.HuanXinTemplate;
import com.tanhua.dubbo.api.UserApi;
import com.tanhua.model.domain.User;
import com.tanhua.server.AppServerApplication;
import com.tanhua.utils.Constants;
import org.apache.dubbo.config.annotation.DubboReference;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import java.time.temporal.Temporal;
import java.util.List;

/**
 * @Description: test
 * @Create by: JJ菜菜
 * @Date: 2021/12/4 22:12
 */
@SpringBootTest(classes = AppServerApplication.class)
@RunWith(SpringRunner.class)
public class Register {

    @DubboReference
    private UserApi userApi;

    @Autowired
    private HuanXinTemplate template;

    @Test
    public void test() {

        List<User> users = userApi.findAll();
        for (User user : users) {
            Boolean create = template.creatUser("hx" + user.getId(), "123456");
            if (create) {
                user.setHxUser("hx" + user.getId());
                user.setHxPassword(Constants.INIT_PASSWORD);
                userApi.update(user);
            }
        }
    }
}
